<%-- 
    Document   : lienheCanhan
    Created on : Dec 18, 2013, 6:20:33 AM
    Author     : Huyen
--%>

<%@page import="bc.entity.Binhluan"%>
<%@page import="businesscard.DAO.BinhluanDAO"%>
<%@page import="bc.entity.Congty"%>
<%@page import="java.util.Date"%>
<%@page import="businesscard.DAO.UserDAO"%>
<%@page import="bc.entity.User"%>
<%@page import="bc.entity.Lienhe"%>
<%@page import="businesscard.DAO.LienheDAO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>


    <div class="lienhemoichiase">

        <%
            User user3 = (User) request.getSession().getAttribute("USER");
            String username1 = user3.getUser();
            UserDAO userDAO1 = new UserDAO();
            User user4 = userDAO1.getUser2(username1);
            int id_user = user4.getIdUser();
            LienheDAO lhDAO = new LienheDAO();
            Lienhe[] lh = lhDAO.getLienHe(id_user);
            for (int i = 0; i < lh.length; i++) {
                int id_lienhe = lh[i].getIdLienhe();
                int id_congty = lh[i].getCongty().getIdCongty();
                String congty = lhDAO.getTenCongty(id_congty);
                String ten = lh[i].getTen();
                String tell = lh[i].getSdtcodinh();
                String mobi = lh[i].getSdt();
                String fax = lh[i].getFax();
                String email1 = lh[i].getEmail();
                String diachi = lh[i].getDiachi();
                String huyen = lh[i].getQuanhuyen().getQuanhuyen();
                String tinh = lh[i].getQuanhuyen().getThanhpho().getThanhpho();
                String capbac = lh[i].getCapbac().getCapbac();
                String bophan = lh[i].getBophan().getBophan();
        %>
        <div class="lienhe">
            <div class="tencty"><%=congty%></div>
            <div class="tenlh"><%=ten%></div>
            <div class="capbac"><%=capbac%> - bộ phận <%=bophan%></div>
            <div class="tell">Tell:<%=tell%> </div>
            <div class="tell">Mobile:<%=mobi%></div>
            <div class="tell">Fax:<%=fax%></div>
            <div class="tell">Email:<%=email1%></div>
            <div class="add">Add:<%=diachi + ", huyện " + huyen + ", tỉnh " + tinh%></div>
        </div>
        <%
            BinhluanDAO A = new BinhluanDAO();
            Binhluan[] B = A.getAllBinhluan(id_lienhe);
            if (B != null) {
                for(int j=0;j<B.length;j++){
        %>
        <div class="comment">
            <div class="hinhdaidien">
                <%
                    int id=B[j].getUser().getIdUser();
                    String link1="avatar/" +A.getLinkHinh(id);
                %>
                <image src="<%=link1%>" style="width: 40px; height: 40px;"/>
            </div>
            <div class="usercmt"><%=B[j].getBinhluan() %></div>
            
        </div>
        <%                    }
            }
        %>
        <div class="like"><a href="#">Like</a></div>
        <div class="binhluan">
            <form action="CommentController" method="post">
            <input type="text" name="binhluan" value=" " placeholder="Viết bình luận..." />
            <input type="hidden" name="binhluanhide" value="<%=id_lienhe %>"/>
            <input type="submit" value="Bình luận" name="action" />   
            </form>
        </div>
        <%
            }
        %>


    </div>
</div>
